package com.wei.jvm;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/**
 * @Author :sunwei
 * @Description:
 * @Date create in 21:58  2021/4/1
 * @Modified by:
 */
public class NewInstanceTets {

    public static void main(String[] args) {
        try {
            Class<?> stringClass = Class.forName("java.lang.String");
            Constructor<?> constructor = stringClass.getConstructor(String.class);
            Object str = constructor.newInstance("ceshi");
            System.out.println(str);
        } catch (ClassNotFoundException | NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }
}
